package com.tzq.autoticket;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

abstract public class ElementWaiter {
    boolean stop = false;

    public ElementWaiter() {
    }

    abstract WebElement get();

    public WebElement waitElement(){
        while (!stop) {
            try {
                return get();
            } catch (Exception e) {
                try {
                    Thread.sleep(75);
                } catch (InterruptedException e1) {
                    e1.printStackTrace();
                    break;
                }
            }
        }
        return null;
    }

    public void stop() {
        stop = true;
    }
}
